/*******************************************************************************
*  Project      : Minigate Golfin                                 
*  Program ID   : home.js                                 
*  Description  : 클럽개별메인 
*
********************************************************************************
*  Program History                                                            
*  Date        Author    Description                                          
*  ----------  --------  -------------------------------------------------------- 
*  2012-06-20  이윤노    Created.  
*  2012-06-00  이윤노    Complete.  
*******************************************************************************/

jQuery(function($){
	
	//라운드정보
	function clsRoundInfo(){
		this._HTMLDom = null;	
		this.roundData = {"라운드키":null};
		
		this._init();
	}
	
	clsRoundInfo.prototype = {
		_init: function(){
			var $layer = $("div#container section#main_content div.golf_board article.board_view");
			this._HTMLDom = {
				"$layer": $layer	
			}
		}
		, setData: function(thisData){
			this.roundData = thisData;			
			this.display();	
		}	
		, addProfile: function(oneData){
			this.roundData["프로필"] = oneData;
		}
		, display: function(){
			var $layer = this._HTMLDom["$layer"];
			var thisClass = this;
			
			$layer.find("dl.view_tit dt").html(this.roundData["라운드명"]);
			$layer.find("dl.view_tit dd span:eq(0) img").attr("src",_gf.filePath2Url(this.roundData["프로필"]["이미지"]));
			$layer.find("dl.view_tit dd span.nickname").html(this.roundData["프로필"]["닉네임"]).hover(function(event){
				_gf.showProfileLayer($(this), thisClass.roundData["프로필"], "left", -12, $(this).height());
			}, function(event){
				_gf.objProfileLayer.hide();
			});
		
			$layer.find("table thead tr:eq(0) th:eq(0) span:eq(1)").html(getFormatDateMd(this.roundData["라운드일자"],".") + "("+ this.roundData["라운드요일"] +")")
			$layer.find("table thead tr:eq(0) th:eq(0) span:eq(2)").html(this.roundData["라운드시간"]);
			$layer.find("table thead tr:eq(0) th:eq(0) span:eq(3)").html(this.roundData["코스명"]);			
			$layer.find("table thead tr:eq(0) th:eq(0) span:eq(4)").html(this.roundData["홀수"] +"H");
			$layer.find("table thead tr:eq(0) th:eq(0) span:eq(5)").html("<strong>"+this.roundData["모집팀수"] +"팀</strong>("+ this.roundData["모집인원수"]+"명)");
			
			$layer.find("table thead tr:eq(0) th:eq(1) span:eq(1) strong").html(this.roundData["신청인원수"]);
			
			if(this.roundData["라운딩진행상태"]=="P") $layer.find("table thead tr:eq(0) th:eq(2) span:eq(1) img").attr("src","http://192.168.0.82/images/btn/btn_ing.png");
			if(this.roundData["라운딩진행상태"]=="C") $layer.find("table thead tr:eq(0) th:eq(2) span:eq(1) img").attr("src","http://192.168.0.82/images/btn/btn_ok.png");
			if(this.roundData["라운딩진행상태"]=="D") $layer.find("table thead tr:eq(0) th:eq(2) span:eq(1) img").attr("src","http://192.168.0.82/images/btn/btn_end.png");
			
			//N=미신청,R=신청완료,A=배정완료
			$layer.find("table thead tr:eq(1) th:eq(0) span:not(:first)").removeClass("point_r").find("img").attr("src","http://192.168.0.82/images/btn/btn_arr02.gif");
			var $tmp=0;			
			if(this.roundData["신청상태"]=="N") $tmp=0;
			if(this.roundData["신청상태"]=="R") $tmp=1;
			if(this.roundData["신청상태"]=="A") $tmp=2;
			$layer.find("table thead  tr:eq(1) th:eq(0) span:odd").eq($tmp).addClass("point_r");
			if($tmp!=0) $layer.find("table thead  tr:eq(1) th:eq(0) span img").eq($tmp).attr("src","http://192.168.0.82/images/btn/btn_arr02_on.gif");
			
			$layer.find("table thead tr:eq(1) th:eq(1) span strong").html(this.roundData["배정완료수"]);
			$layer.find("table thead tr:eq(1) th:eq(2) span:eq(1)").html(getFormatDateYmd(this.roundData["작성일자"],"-") + "<span>"+ getFormatTime(this.roundData["작성시간"],":") + "</span>");			
			
			$layer.find("table tbody td.text").html(this.roundData["내용"]);
			
			if($tmp==0) {
				$("p.btn_area_box>a").eq(0).show();
				$("p.btn_area_box>a").eq(1).hide();
			}else {
				$("p.btn_area_box>a").eq(0).hide();
				$("p.btn_area_box>a").eq(1).show();
			}
			
		}		
		, spinStart: function(){
			 
		}
		, spinEnd: function(){
			
		}		
		, $getBtnAssigning: function(){
			return $("p.rd_time_btn span a:eq(0)");		
		}
		, $getBtnConfirm: function(){
			return $("p.rd_time_btn span a:eq(1)");		
		}
	}
	
	function clsRoundAssign(){
		this._HTMLDom = null;
		this.teamList = null;
		
		this._init();
	}
	
	clsRoundAssign.prototype = {
		_init: function(){
			$layer = $("div#container section#main_content div.golf_board article.board_view div.rd_time_list>ul");	
			this._HTMLDom = {
				"$layer": $layer
				, "$element": $layer.find("li:first")
				, "$comment": $layer.find("div.round_box:eq(0)")
			}
			
			$("div.round_box").hide();
			$layer.empty();
		}
		, setList: function(thisData){
			this.teamList = thisData;
			this.display();
		} 
		, display: function(){
			var $layer = this.	_HTMLDom["$layer"];
			var $element = this._HTMLDom["$element"];
			var thisClass = this;
			
			$layer.empty();
			
			for(var i=0;i<this.teamList.length;++i){
				$layer.append($element.clone(true));
			}
			
			$layer.find("li a").html("&nbsp;");
			
			$layer.find(">li").each(function(n){					
				$(this).find("li:eq(0)").html(thisClass.teamList[n]["팀명"]).click(function(event){
					document.objControl.setTeam(n);
					
				});		
				$(this).find("li:eq(1)").html(thisClass.teamList[n]["라운드시간"] + ":" + thisClass.teamList[n]["라운드분"]);
					
				if(thisClass.teamList[n]["사람1"]) {
					$(this).find("li:eq(2) a").html(thisClass.teamList[n]["사람1"]["닉네임"] + "(1)" ).hover(function(event){
						_gf.showProfileLayer($(this), thisClass.teamList[n]["사람1"], "left", 0, 13);
					}, function(event){
						_gf.closeProfileLayer();
					});
				}else{
					$(this).find("li:eq(2)").addClass("no_con").html("아직 팀 배정이 확정되지 않았습니다.");
				}
				
				if(thisClass.teamList[n]["사람2"]) {
					$(this).find("li:eq(3) a").html(thisClass.teamList[n]["사람2"]["닉네임"] + "(2)" ).hover(function(event){
						_gf.showProfileLayer($(this), thisClass.teamList[n]["사람2"], "left", 0, 13);
					}, function(event){
						_gf.closeProfileLayer();
					});	
				}
				
				if(thisClass.teamList[n]["사람3"]) {
					$(this).find("li:eq(4) a").html(thisClass.teamList[n]["사람3"]["닉네임"] + "(3)" ).hover(function(event){
						_gf.showProfileLayer($(this), thisClass.teamList[n]["사람3"], "left", 0, 13);
					}, function(event){
						_gf.closeProfileLayer();
					});	
				}
				
				if(thisClass.teamList[n]["사람4"]) {
					$(this).find("li:eq(5) a").html(thisClass.teamList[n]["사람4"]["닉네임"] + "(4)" ).hover(function(event){
						_gf.showProfileLayer($(this), thisClass.teamList[n]["사람4"], "left", 0, 13);
					}, function(event){
						_gf.closeProfileLayer();
					});	
				}
			});
		}
		, $getBtnShowTime: function(){
			return $("p.rd_time_btn>a");
		}
		, setShowTime: function(){
			var $layer = this._HTMLDom["$layer"];
			
			if($("div.rd_time_list").is(":visible")) $("div.rd_time_list").hide();
			else $("div.rd_time_list").show();
		}		
	}
	
	function clsRoundReply(){
		this._HTMLDom = null;
		this.replyList = null;
		
		this._init();	
	}
	
	clsRoundReply.prototype = {
		_init: function(){
			$layer = $("div#container section#main_content div.reply_area");
			this._HTMLDom = {
				"$layer": $layer
				, "$element": $layer.find("dl.first:first")
				, "$reply": $layer.find("div.help_box:first")
			}			
		}	
		, setList: function(thisData){
			this.replyList = thisData;
			this.display();
		}
		, addProfile: function(idx, oneData){
			this.replyList[idx]["프로필"] = oneData;
		}
		, display: function(){
			var $layer = this._HTMLDom["$layer"];
			var $element = this._HTMLDom["$element"];
			var $reply = this._HTMLDom["$reply"];
			var thisClass = this;
			
			$layer.find("dl").remove();
			$layer.find("div.help_box").remove();
			
			for(var i=0;i<this.replyList.length;++i){				
				$layer.find("div.reply_regist").before($element.clone(true)).before($reply.clone(true));	
			}
			
			//댓글수
			$layer.find("p.reply_num span").html("("+ getFormatNumber(this.replyList.length) +")");
			//댓글입력칸
			$layer.find("div.reply_regist textarea").val("");
			//댓글목록
			$layer.find("dl").each(function(n){
				$(this).find("dt img").attr("src", _gf.filePath2Url(thisClass.replyList[n]["프로필"]["이미지"]));
				$(this).find("dd p.nickname a").html(thisClass.replyList[n]["프로필"]["닉네임"]).hover(function(event){
					_gf.showProfileLayer($(this), thisClass.replyList[n]["프로필"], "left", -12, $(this).height());
				}, function(event){
					_gf.objProfileLayer.hide();
				});							
				$(this).find("dd p.reply_date").contents().filter(function(){
					return (this.nodeType==3&&this.data.trim())
				}).after(getFormatDateYmd(thisClass.replyList[n]["작성일"],"-")).remove();
				$(this).find("dd p.reply_date span:eq(0)").html(getFormatTime(thisClass.replyList[n]["작성시간"],":"));
				$(this).find("dd div").html(thisClass.replyList[n]["내용"]);
				
				if(thisClass.replyList[n]["본인글"] == "N") $(this).find("dd p.reply_del a img[alt=삭제]").hide();
			}).removeClass("first").eq(0).addClass("first");		
			
			
		}
		, spinStart: function(){
			var $layer = this._HTMLDom["$layer"];
			
			$layer.find("dl").hide();
			if($layer.find("div#tmpSpin").length == 0){
				$layer.append("<div id='tmpSpin' style='position:relative; width:600px; height:100px;'></div>");
			}
			$layer.find("div#tmpSpin").show().spin();
		}
		, spinEnd: function(){
			var $layer = this._HTMLDom["$layer"];
			
			$layer.find("div#tmpSpin").hide().spin(false);
			$layer.find("dl").show();
		}
		, $getBtnDelete: function(){
			return this._HTMLDom["$layer"].find("dd p.reply_del a img[alt=삭제]");
		}
		, $getBtnInsert: function(){
			return this._HTMLDom["$layer"].find("div.reply_regist img[alt=댓글등록]");
		}
		, getReplyText: function(){					
			return this._HTMLDom["$layer"].find("div.reply_regist textarea").val();
		}		
	}
	
	function clsComm()
	{
		this.clubRoundInfo = null;
		this.clubRoundInfoRequest = null;		
		
		this.clubRoundReplyRequest = null;
		
		this._init();
	}
	
	clsComm.prototype = {
		_init: function(){
			this.clubRoundInfoRequest = {
				 "동호회키":null
				, "라운드키": null
				, "페이지": null				
			}
			 
			this.clubRoundReplyRequest = {
				"동호회키": null
				, "라운드키": null
				, "댓글키": null	
			}
		}
//------------------------ 라운드목록------------------------//		
		, getClubRoundInfo: function(){
			var thisClass = this;
			var szClubSeq = this.clubRoundInfoRequest["동호회키"];
			var szRoundSeq = this.clubRoundInfoRequest["라운드키"]
			
			// ajax 시작			
			//parameter setting and run
			_gf.ajax({
				"sid":"CL001",
				"servicename":"getMyClubRoundInfo"
			}, {
				  "clubSeq": szClubSeq
				  ,"roundSeq": szRoundSeq
			}, function(ret){
				
				// callback and mapping			
				if(ret["msp"]["contents"]["items"]){
					
					var obj = ret["msp"]["contents"]["items"];
					var team = obj["roundInfo"]["roundTeamInfoList"][0]["items"];
					var arr = [];
					
					if(team){
												
						if(!team.length){
							team = new Array(team);
						}						
						var user= [];						
						//팀별정보
						for(var k=0;k<team.length;++k){							
							user[k] = [];							
							//팀별 사용자(최대4명) 정보
							for(var m=0;m<4;++m){
								var str = "assignedUser"+ (m+1) +"Info";
								if(team[k][str]){
									user[k][m]={
										"아이디": _util.nvl(team[k][str]["userId"])
										, "이미지": _util.nvl(team[k][str]["path"]) + _util.nvl(team[k][str]["saveFileName"])
										, "닉네임": _util.nvl(team[k][str]["nickname"])
										, "지역": _util.nvl(team[k][str]["region"])
										, "연령대": _util.nvl(team[k][str]["age"])
										, "성별": _util.nvl(team[k][str]["sex"])
										, "핸디": _util.nvl(team[k][str]["handi"])
										, "평타": _util.nvl(team[k][str]["average"])
									}								
								}
							}
							
							arr.push({
								"팀키": _util.nvl(team[k]["teamSeq"])
								, "팀명": _util.nvl(team[k]["teamName"])
								, "라운드시간": _util.nvl(team[k]["roundHour"])
								, "라운드분": _util.nvl(team[k]["roundMinute"])
								, "사람1": _util.nvl(user[k][0])
								, "사람2": _util.nvl(user[k][1])
								, "사람3": _util.nvl(user[k][2])
								, "사람4": _util.nvl(user[k][3])
							});
						}
					}
					
					//동호회목록
					thisClass.clubRoundInfo= {
						"동호회키": _util.nvl(obj["roundInfo"]["clubSeq"])
						, "프로필": {
							"아이디": _util.nvl(obj["userMaster"]["userId"])
							, "닉네임": _util.nvl(obj["userMaster"]["nickname"])
							, "이미지": _util.nvl(obj["userMaster"]["path"]) + _util.nvl(obj["userMaster"]["saveFileName"])
							, "성별": _util.nvl(obj["userMaster"]["sex"])
							, "핸디": _util.nvl(obj["userMaster"]["handi"])
							, "비거리": _util.nvl(obj["userMaster"]["region"])
						} 
						, "라운드키": _util.nvl(obj["roundInfo"]["roundSeq"])
						, "라운드일자": _util.nvl(obj["roundInfo"]["reservDate"])
						, "라운드요일": _util.nvl(obj["roundInfo"]["reservDay"])
						, "라운드시간": _util.nvl(obj["roundInfo"]["firstTime"])
						, "코스명": _util.nvl(obj["roundInfo"]["golfclubCourseInfo"])
						, "홀수": _util.nvl(obj["roundInfo"]["holeInfo"])
						, "라운드명": _util.nvl(obj["roundInfo"]["title"])
						, "모집팀수": _util.nvl(obj["roundInfo"]["totalTeamCnt"])
						, "모집인원수": _util.nvl(obj["roundInfo"]["totalMember"])
						, "신청인원수": _util.nvl(obj["roundInfo"]["requestedMemberCnt"])
						, "배정완료수": _util.nvl(obj["roundInfo"]["assignedMemberCnt"])
						, "라운딩진행상태": _util.nvl(obj["roundInfo"]["procStatus"]) //진행중(0),확정(1),마감(2)													
						, "작성일자": _util.nvl(obj["roundInfo"]["regDate"])
						, "작성시간": _util.nvl(obj["roundInfo"]["regTime"])
						, "신청상태": _util.nvl(obj["roundInfo"]["roundRequestUser"]["assignedStatus"])
						, "내용": _util.nvl(obj["roundInfo"]["detail"])
						, "배정노출유무": _util.nvl(obj["roundInfo"]["assignStatusDispYn"])
						, "팀정보": _util.nvl(arr,[])
					};					
					
				}
			
				$(thisClass).trigger("evtFinishClubRoundInfo");
			});
		}
		, getClubRoundInfoData: function(){
			return this.clubRoundInfo;
		}
		, setClubRoundInfoRequest: function(key, val){
			this.clubRoundInfoRequest[key] = val;
		}
		, getClubRoundInfoRequest: function(key){
			return this.clubRoundInfoRequest[key];
		}	
//------------------------ 라운드목록------------------------//	
//------------------------ 라운드댓글목록------------------------//		
		, getRoundReplyList: function(){			
			var thisClass = this;
		
			var szClubSeq = this.clubRoundReplyRequest["동호회키"];
			var szRoundSeq = this.clubRoundReplyRequest["라운드키"];
			
			// ajax 시작			
			//parameter setting and run
			_gf.ajax({
				"sid":"CL001",
				"servicename":"getRoundReplyList",
				"listcount":9999,
				"currpageno":1
			}, {
				  "clubSeq": szClubSeq
				  , "roundSeq": szRoundSeq
			}, function(ret){
				
				// callback and mapping
				thisClass.clubRoundReplyList = [];
			
				if(ret["msp"]["contents"]["items"]){
					
					if(!ret["msp"]["contents"]["items"].length){
						ret["msp"]["contents"]["items"] = new Array(ret["msp"]["contents"]["items"]);
					}
					
					for(var i=0;i<ret["msp"]["contents"]["items"].length;i++){
						var arr = [];
						var obj = ret["msp"]["contents"]["items"][i];
						
						//동호회목록
						thisClass.clubRoundReplyList.push({
							"동호회키": _util.nvl(obj["clubSeq"])
							, "라운드키": _util.nvl(obj["roundSeq"])
							, "댓글키": _util.nvl(obj["replySeq"])
							, "프로필": {
								"아이디": _util.nvl(obj["regIdInfo"]["userId"])
								, "닉네임": _util.nvl(obj["regIdInfo"]["nickname"])
								, "이미지": _util.nvl(obj["regIdInfo"]["path"]) + _util.nvl(obj["regIdInfo"]["saveFileName"])
								, "성별": _util.nvl(obj["regIdInfo"]["sex"])
								, "핸디": _util.nvl(obj["regIdInfo"]["handi"])
								, "비거리": _util.nvl(obj["regIdInfo"]["region"])
							} 
							, "내용": _util.enter2br(_util.nvl(obj["content"]))
							, "작성일": _util.nvl(obj["regDate"])
							, "작성시간": _util.nvl(obj["regTime"])
							, "본인글": _util.nvl(obj["isMyReply"])
							, "관리자여부": _util.nvl(obj["adminFlag"])
						});
						
					}         
				}
				
				$(thisClass).trigger("evtFinishClubRoundReplyList");
			});			
		}
		, getRoundReplyListData: function(){
			return this.clubRoundReplyList;
		}
		, setClubRoundReplyRequest: function(key, val){
			this.clubRoundReplyRequest[key] = val;
		}
		, getClubRoundReplyRequest: function(key){
			return this.clubRoundReplyRequest[key];
		}	
//------------------------ 라운드댓글목록------------------------//		
//------------------------ 라운드신청------------------------//		

		, InsertAssign: function(arg){			
			var thisClass = this;
					
			var szClubSeq = arg["동호회키"];
			var szRoundSeq = arg["라운드키"];
					
			// ajax 시작			
			//parameter setting and run
			_gf.ajax({
				"sid":"CL001",
				"servicename": "registClubRoundRequestUser"
			}, {
				"clubSeq": szClubSeq
				, "roundSeq": szRoundSeq
			}, function(ret){				
				// callback and mapping
				var resData = {
					"응답코드": (ret["msp"]["contents"]["serviceResult"] == "00000"?true:false)
					, "메세지": _gf.getResultMsg(ret)
				}
				
				$(thisClass).trigger("evtFinishRoundAssign", [resData]);				
			});
			// ajax 끝
		}
//------------------------ 라운드신청------------------------//	
//------------------------ 라운드신청취소------------------------//		

		, CancelAssign: function(arg){			
			var thisClass = this;
					
			var szClubSeq = arg["동호회키"];
			var szRoundSeq = arg["라운드키"];
					
			// ajax 시작			
			//parameter setting and run
			_gf.ajax({
				"sid":"CL001",
				"servicename": "cancelClubRoundRequestUser"
			}, {
				"clubSeq": szClubSeq
				, "roundSeq": szRoundSeq
			}, function(ret){				
				// callback and mapping
				var resData = {
					"응답코드": (ret["msp"]["contents"]["serviceResult"] == "00000"?true:false)
					, "메세지": _gf.getResultMsg(ret)
				}
				
				$(thisClass).trigger("evtFinishRoundAssign", [resData]);
				
			});
			// ajax 끝
		}
//------------------------ 라운드신청취소------------------------//	
//------------------------ 라운드확정------------------------//		

		, ConfirmAssign: function(arg){			
			var thisClass = this;
					
			var szClubSeq = arg["동호회키"];
			var szRoundSeq = arg["라운드키"];
					
			// ajax 시작			
			//parameter setting and run
			_gf.ajax({
				"sid":"CL001",
				"servicename": "confirmRound"
			}, {
				"clubSeq": szClubSeq
				, "roundSeq": szRoundSeq
			}, function(ret){				
				// callback and mapping
				var resData = {
					"응답코드": (ret["msp"]["contents"]["serviceResult"] == "00000"?true:false)
					, "메세지": _gf.getResultMsg(ret)
				}
				
				$(thisClass).trigger("evtFinishRoundAssign", [resData]);
				
			});
			// ajax 끝
		}
//------------------------ 라운드확정------------------------//	
//------------------------ 라운드삭제------------------------//		

		, DeleteRound: function(arg){			
			var thisClass = this;
					
			var szClubSeq = arg["동호회키"];
			var szRoundSeq = arg["라운드키"];
					
			// ajax 시작			
			//parameter setting and run
			_gf.ajax({
				"sid":"CL001",
				"servicename": "deleteClubRound"
			}, {
				"clubSeq": szClubSeq
				, "roundSeq": szRoundSeq
			}, function(ret){				
				// callback and mapping
				var resData = {
					"응답코드": (ret["msp"]["contents"]["serviceResult"] == "00000"?true:false)
					, "메세지": _gf.getResultMsg(ret)
				}
				
				$(thisClass).trigger("evtFinishDeleteRound", [resData]);
				
			});
			// ajax 끝
		}
//------------------------ 라운드삭제------------------------//	
//------------------------ 댓글등록/수정/삭제------------------------//		
		, InsertRoundReply: function(arg){
			var thisClass = this;
			
			var szClubSeq = arg["동호회키"]
			var szRoundSeq = arg["라운드키"];
			var szReplyContens = arg["댓글"];
						
			// ajax 시작			
			//parameter setting and run
			_gf.ajax({
				"sid":"CL001",
				"servicename":"registRoundReply"		
			}, {
				"clubSeq": szClubSeq
				, "roundSeq": szRoundSeq				
				, "content": encodeURIComponent(szReplyContens)
			}, function(ret){
				
				var ret = {
					"응답코드": (ret["msp"]["contents"]["serviceResult"] == "00000"?true:false)
					, "메세지": _gf.getResultMsg(ret)
				}
				
				$(thisClass).trigger("evtFinishCUDBaordViewReply",[ret]);
			});
			// ajax 끝
		}
		//댓글삭제
		, DeleteRoundReply: function(arg){
			var thisClass = this;
			var szClubSeq = arg["동호회키"];
			var szRoundSeq = arg["라운드키"];
			var szReplySeq = arg["댓글키"];
			
			// ajax 시작			
			//parameter setting and run
			_gf.ajax({
				"sid":"CL001",
				"servicename":"deleteRoundReply"		
			}, {
				"clubSeq": szClubSeq
				, "roundSeq": szRoundSeq			
				, "replySeq": szReplySeq
			}, function(ret){
				
				var ret = {
					"응답코드": (ret["msp"]["contents"]["serviceResult"] == "00000"?true:false)
					, "메세지": _gf.getResultMsg(ret)
				}
				
				$(thisClass).trigger("evtFinishCUDBaordViewReply",[ret]);
			});
			// ajax 끝
		}		
//------------------------ 댓글등록/수정/삭제------------------------//		

	}
	
	function clsControl()
	{
		this.objComm = null;
		
		this.objClubInfo = null
		this.objRole = null;
		
		this.objRoundInfo = null;
		this.objRoundAssign = null;
		this.objRoundReply = null;
		
		this.club_seq = null;
		this.club_my = null;
		this.round_seq = null;		
	}
	
	clsControl.prototype = {
		_init: function(){
			var member_id = document.objUtil.getCookie("member_id");
			this.club_seq = document.objUtil.getParam("club_seq");
			this.club_my = (document.objUtil.getParam("club_my") == "Y") ? 1:0;
			this.round_seq = document.objUtil.getParam("round_seq");
			
			if(!this.club_seq) document.location.href = "../club/club.html";
			
			if(!member_id) {
				if(confirm("로그인 후 이용하여 주세요.")){
					_gf.goLogin();						
				}else{
					document.location.href = "../club/club.html";
				}				
			}else if(!this.club_seq) {
				document.location.href = "../club/club.html";
			}
			
			this._preload();
			
			this.objComm = new clsComm();
			this.objRoundInfo = new clsRoundInfo();
			this.objRoundAssign = new clsRoundAssign();
			this.objRoundReply = new clsRoundReply();
			
			this._beforeStart();
			this._bind();
		}
		, _preload: function(){
			_gf.spinStart();
		}
		, _beforeStart: function(){
			var thisClass = this;
			this._permitStart = {
				
			}
			
			$.ajax({
				url: "js/self_club_top.js"
				, dataType: "script"
				, async: false
				, success: function(){
					
				}
				, error: function(){
					alert("error");
				}
			});
			
			_util.executeThread(function(){
				for(var k in thisClass._permitStart){
					if(!thisClass._permitStart[k]) return false;
				}
				
				return (_clubControl.getClubInfo().infoData);
			}, function(){				
				_gf.spinEnd();;
				thisClass._start();
			});	
		}
		, _role: function(){
			if(!this.objRole.isMember()){//0-일반회원, 1-가입대기회원, 9-탈퇴회원
				alert(this.objRole.getError());
				document.location.href = "home.html?club_seq=" + this.infoData["동호회키"];
			}
		
			//개설자(매니저) 인경우만 배정목록표시
			if(!this.objRole.isAdmin()){
				$("p.rd_time_btn").hide();
				$("p.btn_area_box:eq(1)").hide();				
			}else {
				$("p.rd_time_btn").show();
				$("p.btn_area_box:eq(0)").hide();
			}
		}
		, _start: function(){		
			this.objClubInfo = _clubControl.getClubInfo();
			this.objRole = new clsRole(this.objClubInfo.infoData);
			this._role();
			
			//라운드상세정보 조회				
			this.objRoundInfo.spinStart();				
			this.objComm.setClubRoundInfoRequest("동호회키",this.club_seq);
			this.objComm.setClubRoundInfoRequest("라운드키",this.round_seq);
			this.objComm.getClubRoundInfo();
			
			//댓글목록 조회
			this.objComm.setClubRoundReplyRequest("동호회키",this.club_seq);
			this.objComm.setClubRoundReplyRequest("라운드키",this.round_seq);
			this.objComm.getRoundReplyList();
		}
		, _bind: function(){
			var thisClass = this;
			
			//라운드정보 조회 완료 이벤트 
			$(this.objComm).bind("evtFinishClubRoundInfo", function(){
				var thisData = thisClass.objComm.getClubRoundInfoData();
				if(!thisData) {
					alert("조회된 라운드정보가 없습니다.");
					document.location.href="club_admin_rd.html?club_seq=" + thisClass.club_seq;
				}
				thisClass.objRoundInfo.spinEnd();
				thisClass.objRoundInfo.setData(thisData);				
				thisClass.objRoundAssign.setList(thisData["팀정보"]);
			});
			
			//라운드댓글 조회 완료 이벤트 
			$(this.objComm).bind("evtFinishClubRoundReplyList", function(){
				var thisData = thisClass.objComm.getRoundReplyListData();
				
				thisClass.objRoundReply.spinEnd();
				thisClass.objRoundReply.setList(thisData);				
			});
			
			//라운드정보 신청/신청취소/확정 완료 이벤트 
			$(this.objComm).bind("evtFinishRoundAssign", function(event, resData){
				alert(resData["메세지"]);		
				if(resData["응답코드"]){				
					thisClass.objRoundInfo.spinStart();				
					thisClass.objComm.getClubRoundInfo();					
				}				
			});
			
			//라운드 삭제 완료 이벤트 
			$(this.objComm).bind("evtFinishDeleteRound", function(event, resData){
				alert(resData["메세지"]);		
				if(resData["응답코드"]){				
					document.location.href = "club_admin_rd.html?club_seq=" + thisClass.club_seq;
				}				
			});			
			
			// 게시판상세보기댓글 등록/삭제 완료이벤트
			$(this.objComm).bind("evtFinishCUDBaordViewReply", function(event, resData){				
				alert(resData["메세지"]);				
				if(!resData["응답코드"]) return;				
				thisClass.objRoundReply.spinStart();
				thisClass.objComm.getRoundReplyList();			
			});
			
			//팀배정표 펼치기
			thisClass.objRoundAssign.$getBtnShowTime().click(function(){
				event.preventDefault();			
				thisClass.objRoundAssign.setShowTime();					
			});
	
			//팀배정하기
			thisClass.objRoundInfo.$getBtnAssigning().click(function(event){
				event.preventDefault();			
				var _url = "../popup/pop_round.html?club_seq=" + thisClass.club_seq + "&round_seq="+ thisClass.round_seq;
				var winJoinClub = window.open(_url, "winJoinClub", "width=960, height=570, scrollbars=no");
			});
			
			//배정확정하기
			thisClass.objRoundInfo.$getBtnConfirm().click(function(event){
				event.preventDefault();							
				if(!confirm("배정 확정하시면 팀배정 상태가 모두에게 공개됩니다.\n확정하시겠습니까?")){
					return;
				}
				var submitData = {
						"동호회키": thisClass.club_seq
						, "라운드키": thisClass.round_seq
				}
				thisClass.objComm.ConfirmAssign(submitData);
			});
			
			//신청하기
			$("p.btn_area_box a:eq(0)").click(function(event){
				event.preventDefault();				
				var submitData = {
						"동호회키": thisClass.club_seq
						, "라운드키": thisClass.round_seq
				}
				thisClass.objComm.InsertAssign(submitData);
			});
			
			//신청취소
			$("p.btn_area_box a:eq(1)").click(function(event){
				event.preventDefault();				
				var submitData = {
						"동호회키": thisClass.club_seq
						, "라운드키": thisClass.round_seq
				}
				thisClass.objComm.CancelAssign(submitData);
			});
						
			//목록
			$("p.btn_area_box a img[alt=목록]").click(function(event){
				event.preventDefault();				
				document.location.href = "club_admin_rd.html?club_seq="+thisClass.club_seq
			});
			
			//라운드삭제
			$("p.btn_area_box a img[alt=삭제]").click(function(event){
				event.preventDefault();				
				var submitData = {
						"동호회키": thisClass.club_seq
						, "라운드키": thisClass.round_seq
				}
				thisClass.objComm.DeleteRound(submitData);
			});
			
			//라운드수정
			$("p.btn_area_box a img[alt=수정]").click(function(event){
				event.preventDefault();				
				if(thisClass.objRoundInfo.roundData["라운딩진행상태"]=="D"){
					alert("마감된 정보는 수정하실 수 없습니다.");	
					return;
				}
				document.location.href="club_admin_rd_creat.html?club_seq="+ thisClass.club_seq + "&round_seq="+ thisClass.round_seq;
			});
			
			//댓글등록 버튼 이벤트
			this.objRoundReply.$getBtnInsert().click( function(event){
				var replyMsg = thisClass.objRoundReply.getReplyText();
				
				if(!thisClass.objRole.isMember()){
					alert(thisClass.objRole.getError());
					return;
				}
				
				if(!_gf.validComment(replyMsg)){
			     return;
			   }
			   
				var submitData = {
					"동호회키": thisClass.club_seq 
					, "라운드키" : thisClass.round_seq
					, "댓글": replyMsg
				} 
				
				thisClass.objComm.InsertRoundReply(submitData);
			});
			
			//댓글삭제 버튼이벤트
			this.objRoundReply.$getBtnDelete().live("click", function(event){
				event.preventDefault();				
				
				var n = thisClass.objRoundReply.$getBtnDelete().index($(this));
				var submitData = {
					"동호회키": thisClass.club_seq 
					, "라운드키" : thisClass.round_seq
					, "댓글키": thisClass.objRoundReply.replyList[n]["댓글키"]
				} 
				
				thisClass.objComm.DeleteRoundReply(submitData);
			});
		}
		, parentReload: function(){
			this.objRoundInfo.spinStart();				
			this.objComm.setClubRoundInfoRequest("동호회키",this.club_seq);
			this.objComm.setClubRoundInfoRequest("라운드키",this.round_seq);
			this.objComm.getClubRoundInfo();
		}
		//팀배정하기
		, setTeam: function(n){
			if(!this.objRole.isAdmin()){//0-일반회원, 1-가입대기회원, 9-탈퇴회원
				return;
			}
			var _url = "../popup/pop_round.html?club_seq=" + this.club_seq + "&round_seq="+ this.round_seq + "&team_seq=" + this.objRoundAssign.teamList[n]["팀키"];
			var winJoinClub = window.open(_url, "winJoinClub", "width=960, height=570, scrollbars=no");	
		}
	}
	
	document.objControl = new clsControl();
	document.objControl._init();
});